﻿using System.Collections.Generic;
using MostRecentlyUsed.Models.EventArguments;

namespace MostRecentlyUsed.Interfaces
{
    /// <summary>
    /// Menu item for managing most recently used database connections
    /// </summary>
    public interface IDatabaseConnections
    {
        /// <summary>
        /// List of connection strings (unencrypted)
        /// </summary>
        List<SelectedConnectionString> ConnectionStrings { get; }

        /// <summary>
        /// Object for handling encrytion/decryption of the connection strings for persistent secure storage
        /// </summary>
        IEncryption EncryptionClass { get; set; }

        /// <summary>
        /// Maximum number of items to display in the Most Recent list
        /// </summary>
        int MaximumNumberOfItems { get; set; }

        /// <summary>
        /// Password Hash
        /// </summary>
        string PasswordHash { get; set; }

        /// <summary>
        /// Salt key
        /// </summary>
        string SaltKey { get; set; }

        /// <summary>
        /// Occurs when a menu item is clicked on
        /// </summary>
        event ItemSelectedEventHandler ItemSelectedEvent;

        /// <summary>
        /// Adds a new item to the connection string list; it the item already exists, it is promoted to the top of the list.  Items beyond the <see cref="MaximumNumberOfItems"/> are removed
        /// </summary>
        /// <param name="connectionString">Connection string to store</param>
        /// <param name="provider">Database provider</param>
        void AddItem(string connectionString, string provider);

        /// <summary>
        /// Check to see whether a given connection string is already in the list
        /// </summary>
        /// <param name="connectionString">Connection string</param>
        /// <returns>True if connection string already exists</returns>
        bool Contains(string connectionString);

        /// <summary>
        /// Gets the connection string items as an encrypted string for secure persistent storage
        /// </summary>
        /// <returns>Encrypted string</returns>
        string GetEncryptedConnectionStrings();

        /// <summary>
        /// Removes a connection string by using it's display name as the key
        /// </summary>
        /// <param name="displayName">Display name</param>
        void RemoveItemByDisplayName(string displayName);

        /// <summary>
        /// Decrypts the value into the connection strings items
        /// </summary>
        /// <param name="value">Encrypted connection strings</param>
        void SetEncryptedConnectionStrings(string value);
    }
}